fix: VLLM Supplier Dialogue Verification#2412
Merged
shaohuzhang1 merged 1 commit intomainfrom Feb 26, 2025
Merged
Conversation
shaohuzhang1
commented
Feb 26, 2025
| error=str(e))) | ||
| return True | ||
|
|
||
| def encryption_dict(self, model_info: Dict[str, object]): |
Contributor
Author
There was a problem hiding this comment.
The code looks mostly well-written, but there's one issue that needs improvement: the exception handling for invalid calls to get_model might not be sufficient for all cases.
Improvement Suggestions:
- Ensure Proper Error Handling: Add checks after calling
get_model()to verify ifmodelis not null or returns an error value before attempting to invoke it. This can help prevent unexpected failures from unhandled errors.def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params): # Ensure proper model retrieval and initial validation model = provider.get_model(model_type, model_name, model_credential, **model_params) if model is None: # Handle case where model retrieval fails raise AppApiException(ValidCode.model_not_found.value, gettext('Model not found')) try: res = model.invoke([HumanMessage(content=gettext('Hello'))]) # Print response for debugging purposes (optional) except Exception as e: raise AppApiException(ValidCode.valid_error.value, gettext('Verification failed, please check whether the parameters are correct: {error}') .format(error=str(e))) return True
By adding these modifications, you improve robustness by checking if the model was successfully retrieved before proceeding with other operations, which can reduce runtime exceptions due to missing models. Also note that using None here is more precise than relying on truthiness for provider.get_model() responses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: VLLM Supplier Dialogue Verification